<template>
  <zm-dialog
    title="评论"
    :visible.sync="value"
    @change="dialogClose"
    size="small"
    :before-close="dialogClose"
    :close-on-click-modal="false"
  >
    <zm-form :model="form" ref="form" :rules="Rules" label-width="0px">
      <el-form-item label="" prop="content">
        <zm-input
          type="textarea"
          v-model="form.content"
          placeholder="请输入评论内容"
          :autosize="{ minRows: 3 }"
          :maxlength="300"
          class="w570"
        />
      </el-form-item>
    </zm-form>
    <div slot="footer" class="tr">
      <el-button size="small" @click="dialogClose">取消</el-button>
      <el-button type="primary" size="small" @click="submit">确定</el-button>
    </div>
  </zm-dialog>
</template>

<script>
import dialogMixin from '@/mixins/dialogMixin'
import {comment} from '@/api/src/follow'

export default {
  name: 'FollowComment',
  components: {},
  mixins: [dialogMixin],
  prop: {},
  data () {
    return {
      form: {
        content: ''
      },
      Rules: {
        content: { required: true, message: '请输入评论内容', trigger: 'blur' }
      }
    }
  },

  methods: {
    async submit () {
      let _valid = false
      this.$refs.form.validate(valid => {
        _valid = valid
      })
      if (!_valid) return
      await comment({ id: this.id, content: this.form.content })
      this.$message.success('评论成功')
      this.$emit('after')
      this.dialogClose()
    }
  }
}
</script>

<style></style>
